﻿function openNewDiv(id) {
    //mask遮罩层
    var newMask = document.createElement("div");
    newMask.id = "mask";
    newMask.style.position = "absolute";
    newMask.style.zIndex = "1";
    newMask.style.width = document.body.clientWidth + "px";
    newMask.style.height = document.body.clientHeight + "px";
    newMask.style.top = "0px";
    newMask.style.left = "0px";
    newMask.style.background = "#33393C";
    newMask.style.filter = "alpha(opacity=40)";
    newMask.style.opacity = "0.50";
    document.body.appendChild(newMask);
    //新弹出层
    var newDiv = document.getElementById(id);
    newDiv.style.display = "block";
    newDiv.style.position = "absolute";
    newDiv.style.zIndex = "9999";
    newDiv.style.background = "#EFEFEF";
//   document.documentElement.style.overflow = 'hidden'; //去除页面滚动条

    autoMargin(id)
}
function CloseMast(id) {
    try {
        document.body.removeChild(document.getElementById("mask"));
        document.getElementById(id).style.display = "none";
    } catch (e) { }
}

function autoMargin(id) {
    var mainEle = document.getElementById(id);
    mainEle.style.left = (document.body.clientWidth - mainEle.style.width.substr(0, 3)) / 2 + "px";
    mainEle.style.top = (document.body.clientHeight - mainEle.style.height.substr(0, 3)) / 2 + "px";
}